package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class  ReviseOperation implements IOperation{
    @Override
    public void work(BookList books) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("修改图书");
        System.out.println("请输入要修改的图书的书名 ");
        String name=scanner.next();
        for (int i=0;i<books.getUserSize();i++) {
            Book book= books.getBooks(i);//将返回的引用给book
            if(book.getName().equals(name))//用book去调用Book类的getName
            {
                System.out.println("输入书名:");
                name=scanner.next();
                System.out.println("请输入作者:");
                String author=scanner.next();
                System.out.println("请输入价格:");
                int price=scanner.nextInt();
                System.out.println("请输入类型:");
                String type=scanner.next();
                Book book1=new Book(name,author,price,type);
                books.setBooks(book1,i);
                System.out.println("修改成功！！！");
                return;
            }
        }
        System.out.println("没有找到该图书!");
    }
}
